#ifndef CVNETWORKMANAGER_H
#define CVNETWORKMANAGER_H

#include <QObject>
#include <QUrl>
#include <QtScript/QScriptEngine>
#include <QtScript/QScriptValue>

#include "cvsession.h"
#include "util/cvutil.h"
#include "http/cvhttp.h"
#include "model/cvnetwork.h"

class CVNetworkManager : public QObject
{
    Q_OBJECT
public:
    virtual ~CVNetworkManager();
    static CVNetworkManager *get();
    static void clear();

    void validateNetwork(const QString &url);
signals:
    void validated(bool result);
    void getNetworkSignal(CVNetwork *network, const QString errorMessage);
public slots:
private slots:
    void handleData(QScriptValue result, const QString &message);
    void handError(QNetworkReply::NetworkError error);
private:
    CVNetworkManager();

    static CVNetworkManager *instance;
};

#endif // CVNETWORKMANAGER_H
